﻿@model qltscd.Models.ScreenClient.DMLDTScreenClient

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/Modules/_LayoutDanhMucNhapLieu.cshtml";
}
<script>
    function confirmXoa() {
        var idLDT = document.getElementById('idLDT').value;
        if (idLDT == null || idLDT == '-1') {
            alert("Chọn lý do trước");
        } else {
            if (confirm("Bạn có muốn xóa lý do này?")) {
                document.location = "/QuanLyThietBi/DanhMucLyDoTang/XoaLyDoTang?id=" + idLDT;
            }
        }
    }

    function confirmSua() {
        var idLDT = document.getElementById('idLDT').value;
        if (idLDT == null || idLDT == '-1') {
            alert("Chọn lý do trước");
        } else {
            document.location = "/QuanLyThietBi/DanhMucLyDoTang/SuaLyDoTang?id=" + idLDT;
        }
    }

    function onCheck(id) {
        document.getElementById('idLDT').value = id;
    }
</script>

<h2>Lý do tăng</h2>
<input type="hidden" value="-1" id="idLDT" name="idLDT"/>
@{
    Html.Telerik().Grid(Model.DSLyDoTang)
    .Name("grdDSLDT")
    .DataKeys(keys => keys.Add(c => c.IdentityLyDoTang))
    .Resizable(r => r.Columns(true))
    .Reorderable(r => r.Columns(true))
    .Sortable()
    .Pageable(paging => paging.Enabled(true).Style(GridPagerStyles.NextPreviousAndInput).PageSize(15))
    //.Editable(editing => editing.Mode(GridEditMode.InCell))
    .ToolBar(t => {
        t.Custom()
            .Action("Create", "DanhMucLyDoTang")
            .ButtonType(GridButtonType.ImageAndText)
            .ImageHtmlAttributes(new { @class = "t-icon t-add" })
            .Text("Thêm lý do");
        //t.SubmitChanges().ButtonType(GridButtonType.ImageAndText).SaveText("Lưu").CancelText("Hủy bỏ");
        t.Custom()
           .Text("Xóa lý do")
           .ButtonType(GridButtonType.ImageAndText)
           .Url("#")
           .HtmlAttributes(new { @onclick = "confirmXoa()" })
           .ImageHtmlAttributes(new { @style = "background-image: url('./../../../../../QuanLyThietBi/Content/Images/cross.png')" });
        t.Custom()
           .Text("Sửa lý do")
           .ButtonType(GridButtonType.ImageAndText)
           .Url("#")
           .HtmlAttributes(new { @onclick = "confirmSua()" })
           .ImageHtmlAttributes(new { @style = "background-image: url('./../../../../../QuanLyThietBi/Content/Images/hammer.png')" });
        t.Custom()
            .Text("In PDF")
            .Action("ShowPdf", "DanhMucLyDoTang")
            .ButtonType(GridButtonType.ImageAndText)
            .ImageHtmlAttributes(new {
                @style = "background-image: url('./../../../../QuanLyThietBi/Content/Images/printer.png');"
            });
        t.Custom()
            .Text("Xuất Excel")
            .Action("ExportToExcel", "DanhMucLyDoTang")
            .ButtonType(GridButtonType.ImageAndText)
            .ImageHtmlAttributes(new
            {
                @style = "background-image: url('./../../../../QuanLyThietBi/Content/Images/printer.png');"
            });
    })
    .DataBinding(databinding => {
        databinding.Server()
            .Select("Index", "DanhMucLyDoTang");
        databinding.Ajax()
            .Select("_Index", "DanhMucLyDoTang")
            .Insert("_Insert", "DanhMucLyDoTang")
            .Delete("_Delete", "DanhMucLyDoTang")
            .Update("_Update", "DanhMucLyDoTang");
    })
    .Columns(column => {
        column.Template(
                @<text>
                    <input name="checkedRecords" type="radio" title="checkedRecords" value="@item.IdentityLyDoTang" onclick="onCheck(@item.IdentityLyDoTang)"/>
                </text>)
            .ClientTemplate("<input type='radio' name='checkedRecords' value='<#=IdentityLyDoTang#>'  onclick='onCheck(<#=IdentityLyDoTang#>)'/>")
            .Title("").Width(50);
                column.Bound(o => o.MaLyDoTang).Title("Mã Lý Do Tăng");
                column.Bound(o => o.TenLyDoTang).Title("Tên Lý Do Tăng");
                //column.Command(c => {
                //    c.Custom("Delete")
                //    .ButtonType(GridButtonType.Image)
                //    .Action("Delete", "DanhMucNhaCungCap")
                //    .ImageHtmlAttributes(new { @class = "t-icon t-delete" });     
                //}).Width(50);
    })
    .Render();
    }


